home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18234 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: camelot.dsccc.com!kcline
  2. From: kcline@sun132.spd.dsccc.com (Kevin Cline)
  3. Newsgroups: comp.sys.sgi.apps,comp.lang.c++
  4. Subject: Re: SGI's C++ compiler and the boolean type
  5. Date: 19 Apr 1996 15:04:04 GMT
  6. Organization: DSC Communications Corporation Switch Products Division
  7. Message-ID: <4l8a14$5g@tpd.dsccc.com>
  8. References: <4kefm7$oao@ncar.ucar.edu> <4kg6fv$h7k@nic.ftns.no> <31770390.2781@llnl.gov>
  9. NNTP-Posting-Host: sun132.spd.dsccc.com
  10.  
  11.  In article <31770390.2781@llnl.gov>, Scott Nelson  <nelson18@llnl.gov> wrote:
  12.  >Arthur Hagen wrote:
  13.  >> 
  14.  >> >
  15.  >> > typedef int     bool;
  16.  >> > #define true    1
  17.  >> > #define false   0
  18.  >> 
  19.  >> And some argue that true should be -1, because then bitwise not works:
  20.  >> 
  21.  >
  22.  >We use the following.  It's safe on all platforms:
  23.  >
  24.  >#define FALSE    0
  25.  >#define TRUE   (!0)
  26.  >
  27.  >Let the built-in ! operator determine what TRUE really is.
  28.  >
  29.  >Scott Nelson
  30.  
  31. The real lesson here is to write
  32.     if (x) 
  33. or
  34.     if (!x)
  35.  
  36. instead of
  37.     if (x == true)
  38. and
  39.     if (x == false)
  40.  
  41. Then it doesn't matter what the value of true is, as long as it is not zero.  
  42. -- 
  43. Kevin Cline
  44.